package com.lx.demo;

import com.alibaba.dubbo.config.spring.context.annotation.DubboComponentScan;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubboConfig;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ImportResource;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.util.Arrays;

import static com.lx.demo.Start.*;
import static org.hibernate.validator.internal.util.Contracts.assertNotNull;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: lanyXp
 * @Date: 2021/09/10/11:11
 * @Description: 项目启动入口
 */
@Slf4j
@EnableDubboConfig
@SpringBootApplication(scanBasePackages = {LCN_BASE_SCAN_PACKAGE, PROJECT_BASE_SCAN_PACKAGE})
@EnableTransactionManagement(proxyTargetClass = true)
@DubboComponentScan(DUBBO_BASE_SCAN_PACKAGE)
@ImportResource(locations = {DUBBO_LOCAL_FILE_PATH})
@MapperScan(MYBATIS_BASE_SCAN_PACKAGE)
public class Start extends SpringBootServletInitializer {

    public static final String DUBBO_BASE_SCAN_PACKAGE = "com.lx.demo.service.*";
    public static final String MYBATIS_BASE_SCAN_PACKAGE = "com.lx.demo.dal.mapper";
    public static final String LCN_BASE_SCAN_PACKAGE = "com.codingapi.tx.*";
    public static final String PROJECT_BASE_SCAN_PACKAGE = "com.lx.demo.*";
    public static final String DUBBO_LOCAL_FILE_PATH = "classpath:dubbo.xml";

    public static void main(String[] args) {
        SpringApplication.run(Start.class, args);
        log.info("启动成功");
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(Start.class);
    }
}